//
//  DYShopOrderFooterView.m
//  TerritoryShopkeeper
//
//  Created by 黄德玉 on 2018/7/9.
//  Copyright © 2018年 ZDQK. All rights reserved.
//

#import "DYShopOrderFooterView.h"
#import <Masonry/Masonry.h>

@implementation DYShopOrderFooterView

- (instancetype)init{
    if (self = [super init]) {
        self.leftBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.leftBtn setTitle:@"大卖场" forState:UIControlStateNormal];
        [self.leftBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
        self.leftBtn.tag = 0;
        self.leftBtn.backgroundColor = [UIColor colorWithHex:0x61b9dc alpha:1];
        [self.leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.leftBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
        self.leftBtn.selected = YES;
        self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.rightBtn setTitle:@"自营" forState:UIControlStateNormal];
        [self.rightBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
        self.rightBtn.tag = 1;
        self.rightBtn.backgroundColor = [UIColor colorWithHex:0x52dea6  alpha:1];
        [self.rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.rightBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
        
        [self addSubview:self.leftBtn];
        [self addSubview:self.rightBtn];
        
        [self.leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(self);
            make.width.equalTo(self).multipliedBy(.5);
            make.height.equalTo(@50);
        }];
        [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.right.equalTo(self);
            make.width.equalTo(self).multipliedBy(.5);
        }];
    }
    return self;
}

- (void)btnClicked:(UIButton *)btn{
    if (btn.isSelected) {
        return;
    } else {
        self.leftBtn.selected = NO;
        self.rightBtn.selected = NO;
        btn.selected = YES;
    }
    if (self.didSelectedFooterBlock) {
        self.didSelectedFooterBlock(btn.tag);
    }
}



@end
